1 /**
2 Copyright: Copyright (c) 2018, Joakim Brännström. All rights reserved.
3 License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
4 Author: Joakim Brännström (joakim.brannstrom@gmx.com)
5 */
6 module test_logging;
7 
8 import config;
9 
10 @("shall create a log file")
11 unittest {
12     auto ta = TestArea(__FILE__, __LINE__);
13 
14     run([codeCherckerBin, "--init"], ta).status.shouldEqual(0);
15     run([codeCherckerBin, "--log", "--compile-db", buildPath(testData, "log").absolutePath], ta)
16         .status.shouldEqual(1);
17 
18     // 2 because it should be one configuration file and one logfile
19     dirEntries(ta, SpanMode.shallow).count.shouldEqual(2);
20 }
21 
22 @("shall create logs in the specified directory")
23 unittest {
24     auto ta = TestArea(__FILE__, __LINE__);
25 
26     run([codeCherckerBin, "--init"], ta).status.shouldEqual(0);
27     run([codeCherckerBin, "--log", "--logdir", "log", "--compile-db",
28             buildPath(testData, "log").absolutePath], ta).status.shouldEqual(1);
29 
30     // 1 because it is separated from the config file
31     dirEntries(buildPath(ta, "log"), SpanMode.shallow).count.shouldEqual(1);
32 }
33 
34 @("shall create a log file and a yaml fixit log")
35 unittest {
36     auto ta = TestArea(__FILE__, __LINE__);
37     copy(buildPath(testData, "log", "compile_commands.json"), buildPath(ta,
38             "compile_commands.json"));
39     copy(buildPath(testData, "log", "empty.cpp"), buildPath(ta, "empty.cpp"));
40 
41     run([codeCherckerBin, "--init"], ta).status.shouldEqual(0);
42     run([codeCherckerBin, "--clang-tidy-fix", "--log"], ta).status.shouldEqual(1);
43 
44     // 4 because it should be one configuration file, one logfile, one compile_commands.json and one yaml file
45     dirEntries(ta, SpanMode.shallow).count.shouldEqual(4);
46 }